package base.Day03.exercise;

import java.util.Scanner;

public class test1
{
    public static void main(String[] args)
    {
        test1 t = new test1();
        t.question1();
        System.out.println("-------------------");
        t.question2();
        System.out.println("--------------------");
        t.question3();
        System.out.println("--------------------");
        t.question4();
        System.out.println("--------------------");

    }

    public void question1()
    {
        //声明两个整型变量a和b并分别赋值，找到a和b中的最大值，并输出。用两种方式实现：条件运算符、if..else分支结构。
        int a = 10;
        int b = 20;
        int max = a > b ? a : b;
        System.out.println("max =" + max);

        int max1 = a;
        if (a > b)
        {
            System.out.println("....");
        } else
        {
            max1 = b;
        }
        System.out.println("max1 = " + max1);
    }

    void question2()
    {
        //声明一个整型变量year并存储年份，判断其是平年还是闰年，若是闰年则输出"某某某年是闰年"，否则输出"某某某年是平年"。
        int year = 2014;
        if (year % 4 == 0 && year % 100 != 0)
        {
            System.out.println(year + "是闰年");
        } else
        {
            System.out.println(year + "是平年");
        }
    }

    void question3()
    {
        //成绩等级判断：A:成绩大于等于90
        //B:成绩大于等于80并且小于90
        //C:成绩大于等于60并且小于80
        //D:成绩小于60
        Scanner scanner = new Scanner(System.in);
        double score = scanner.nextDouble();
        if (score >= 90)
        {
            System.out.println("A");
        } else if (score >= 80)
        {
            System.out.println("B");
        } else if (score >= 70)
        {
            System.out.println("C");
        } else if (score >= 60)
        {
            System.out.println("D");
        } else if (score >= 50)
        {
            System.out.println("E");
        } else
        {
            System.out.println("fvv");
        }
    }

    void question4()
    {
        // 接收用户输入的年份year和月份month，计算该年该月的天数，并输出
        Scanner scanner = new Scanner(System.in);
        System.out.println("年份 :");
        int year = scanner.nextInt();
        System.out.println("月份 :");
        int month = scanner.nextInt();
        switch (month)
        {
            case 1:
            case 12:
            case 10:
            case 8:
            case 7:
            case 5:
            case 3:
                System.out.println(31);
                break;
            case 2:
                if(year % 4 == 0 && year % 100 != 0)
                {
                    System.out.println(29);
                }else
                {
                    System.out.println(28);
                }
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println(30);
                break;
        }
    }
}

